﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Forms;
using System.IO;

namespace BDSim
{
    /// <summary>
    /// ExportSpaceEnvFile.xaml 的交互逻辑
    /// </summary>
    public partial class ExportSpaceEnvFile : Window
    {
        public ExportSpaceEnvFile(int type, string filename)
        {
            InitializeComponent();
            if (type == 1)
            {
                this.Title = "气象参数导出文件";
            }
            if (type == 2)
            {
                this.Title = "电离层VTEC导出文件";
            }
            int index = filename.LastIndexOf('\\');
            textBoxPath.Text = filename.Substring(0, index+1);
            textBoxName.Text = filename.Substring(index+1);
        }

        //数据定义
        private bool selResult = false;
        public bool SelResult
        {
            get { return selResult; }
            set { selResult = value; }
        }
        private string fileName = "";
        public string FileName
        {
            get { return fileName; }
            set { fileName = value; }
        }
       
        //事件方法
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = "文本文件(*.txt)|*.txt";
            sfd.InitialDirectory = textBoxPath.Text;
            sfd.FileName = textBoxName.Text;
            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {               
                int index = sfd.FileName.LastIndexOf('\\');
                textBoxPath.Text = sfd.FileName.Substring(0, index + 1);
                textBoxName.Text = sfd.FileName.Substring(index + 1);
            }
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            this.FileName = textBoxPath.Text + textBoxName.Text;
            this.selResult = true;
            this.Close();
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            this.selResult = false;
            this.Close();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.selResult = false;
        }
    }
}
